package elicecn.web.struts2.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public abstract class BaseAction extends ActionSupport {

	public static String getBaseUrl() {
		HttpServletRequest req = ServletActionContext.getRequest();
		String url = "http://" + req.getServerName();
		int port = req.getServerPort();
		if (port != 80) {
			url += ":" + port;
		}
		url += req.getContextPath();
		return url;
	}

	@SuppressWarnings("unchecked")
	public static Map getContextSession() {
		return ActionContext.getContext().getSession();
	}
}
